<?php

    namespace Admin\Controller;

    use Common\Controller\AdminbaseController;

    class CardReplaceController extends AdminbaseController {

        protected $m_card;
        protected $m_card_replace;

        function _initialize() {
            parent::_initialize();
            $this->m_card= D("Admin/Card");
            $this->m_card_replace= D("Admin/CardReplace");
        }

        /**
         * 更换卡片
         */
        public function index(){
            if(IS_POST){
                $old_card_number = I("post.old_card_number");
                $old_card = $this->m_card->get_one(['number'=>$old_card_number]);
                if(empty($old_card)){
                    $this->error("原卡号不存在");exit;
                }
                if($old_card['status'] != 1){
                    $this->error("原卡号已注销");exit;
                }


            }
            $this->display();
        }


        /**
         *  更换明细
         */
        public function replace_detail(){
            $count = $this->m_recharge_rebate->count();
            $page = $this->page($count, 15);
            $list = $this->m_recharge_rebate->get_list([],$page->firstRow, $page->listRows);
            $this->assign("page", $page->show('Admin'));
            $this->assign("list",$list);
            $this->display();
        }


    }